package ABB;

import java.util.*;

public class Company {
    private String name;
    private String ad;
    private String tel;
    private String area;
    Map<String,Staff> staff=new HashMap<>();

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAd() {
        return ad;
    }

    public void setAd(String ad) {
        this.ad = ad;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public String getArea() {
        return area;
    }

    public void setArea(String area) {
        this.area = area;
    }

    public Company() {
    }

    public Company(String name, String ad, String tel, String area) {
        this.name = name;
        this.ad = ad;
        this.tel = tel;
        this.area = area;
    }

    public void add(String gonghao,Staff s){
        for(int i=0;i<staff.size();i++ ){
            if(staff.containsKey(gonghao)){
                System.out.println("添加信息失败，工号重复");
                return;
            }
        }
        staff.put(gonghao,s);
        System.out.println("员工信息录入成功");
    }
    public void citui(String gonghao){
        if(staff.containsKey(gonghao)){
            System.out.println(staff.get(gonghao));
            staff.remove(gonghao);
            System.out.println("辞退成功，信息已删除");
        }else{
            System.out.println("辞退失败");
        }
    }
    public int num(){
        return staff.size();
    }

    public double salarymax(){
        Set<Map.Entry<String, Staff>> entries = staff.entrySet();
        Iterator<Map.Entry<String, Staff>> iterator = entries.iterator();
        double max=0;
        while (iterator.hasNext()) {
            Map.Entry<String, Staff> next =  iterator.next();
            max=max>=next.getValue().getSalary()?max:(next.getValue().getSalary());
        }
        return max;
    }
    public void staffshow(){
        System.out.println(staff);
    }

}
